package com.example.myyunpan.entity.vo;


import com.example.myyunpan.entity.dto.SessionWebUserDto;
import com.example.myyunpan.entity.enums.ResponseCodeEnum;

public class ResponseVO<T> {
    private String status;
    private Integer code;
    private String info;
    private T data;



    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    // 成功响应方法
    public static <T> ResponseVO<T> success() {
        ResponseVO<T> response = new ResponseVO<>();
        response.setStatus("success");
        response.setCode(ResponseCodeEnum.CODE_200.getCode());
        response.setInfo(ResponseCodeEnum.CODE_200.getMsg());
        response.setData(null);
        return response;
    }

    /**
     * @return com.example.myyunpan.entity.vo.ResponseVO<T>
     * @param @param data
     * @author znk
     * @date 2024/10/26 18:03
     * 有数据的成功的响应
     */
    public static <T> ResponseVO<T> success(T data) {
        ResponseVO<T> response = new ResponseVO<>();
        response.setStatus("success");
        response.setCode(ResponseCodeEnum.CODE_200.getCode());
        response.setInfo(ResponseCodeEnum.CODE_200.getMsg());
        response.setData(data);
        return response;
    }

    // 失败响应方法
    public static <T> ResponseVO<T> fail(ResponseCodeEnum codeEnum) {
        ResponseVO<T> response = new ResponseVO<>();
        response.setStatus("fail");
        response.setCode(codeEnum.getCode());
        response.setInfo(codeEnum.getMsg());
        response.setData(null);
        return response;
    }

    /**
     * @return com.example.myyunpan.entity.vo.ResponseVO<T>
     * @param @param codeEnum
    	* @param data
     * @author znk
     * @date 2024/10/26 18:03
     * 有数据的失败响应
     */
    public static <T> ResponseVO<T> fail(ResponseCodeEnum codeEnum, T data) {
        ResponseVO<T> response = new ResponseVO<>();
        response.setStatus("fail");
        response.setCode(codeEnum.getCode());
        response.setInfo(codeEnum.getMsg());
        response.setData(data);
        return response;
    }

}
